package KinoVerwaltung;


import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import java.awt.SystemColor;
import javax.swing.JLayeredPane;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JFormattedTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import javax.swing.JTabbedPane;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager;
import userVerwaltung.*;
import filmVerwaltung.*;
import veranstaltungsverwaltung.*;
import raumVerwaltung.*;
import db.*;
import takeASeat.*;


public class Kinoverwaltung extends JFrame implements ActionListener {

	private JPanel contentPane;
	private JPasswordField passwordField;
	private Color col = UIManager.getColor("Button.background");
	private Database db;


	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Kinoverwaltung frame = new Kinoverwaltung();
					frame.setVisible(true);
					frame.setLocation(300, 50);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Kinoverwaltung() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 747, 587);
		contentPane = new JPanel();
		contentPane.setBackground(SystemColor.activeCaption);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		db = new Database("jdbc:mysql://sql3.freesqldatabase.com:3306/sql311803", "sql311803", "gC2!qS3%");

		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setFont(new Font("Verdana", Font.PLAIN, 12));
		tabbedPane.setBackground(SystemColor.inactiveCaptionBorder);

		JLabel lblNewLabel = new JLabel("Take A Seat - Kinoverwaltung");
		lblNewLabel.setForeground(Color.WHITE);
		lblNewLabel.setFont(new Font("Verdana", Font.BOLD, 36));
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(gl_contentPane
				.createParallelGroup(Alignment.LEADING)
				.addGroup(
						gl_contentPane.createSequentialGroup()
								.addContainerGap().addComponent(lblNewLabel)
								.addContainerGap(125, Short.MAX_VALUE))
				.addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 807,
						Short.MAX_VALUE));
		gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(
				Alignment.TRAILING).addGroup(
				Alignment.LEADING,
				gl_contentPane
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(lblNewLabel)
						.addGap(18)
						.addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE,
								525, Short.MAX_VALUE)));
		gl_contentPane.setHonorsVisibility(false);

		JPanel panel_login = new JPanel();
		tabbedPane.addTab("Login", null, panel_login, null);

		JLabel lblBenutzername = new JLabel("Benutzername");
		lblBenutzername.setFont(new Font("Verdana", Font.BOLD, 18));

		JLabel lblPassword = new JLabel("Password");
		lblPassword.setFont(new Font("Verdana", Font.BOLD, 18));

		passwordField = new JPasswordField();
		passwordField.setFont(new Font("Verdana", Font.BOLD, 14));

		JFormattedTextField formattedTextField = new JFormattedTextField();
		formattedTextField.setFont(new Font("Verdana", Font.BOLD, 14));

		JButton btnLogin = new JButton("Login");
		btnLogin.setFont(new Font("Verdana", Font.PLAIN, 12));
		GroupLayout gl_panel_login = new GroupLayout(panel_login);
		gl_panel_login
				.setHorizontalGroup(gl_panel_login
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_panel_login
										.createSequentialGroup()
										.addGap(57)
										.addGroup(
												gl_panel_login
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																lblPassword)
														.addComponent(
																lblBenutzername))
										.addGap(28)
										.addGroup(
												gl_panel_login
														.createParallelGroup(
																Alignment.LEADING,
																false)
														.addComponent(
																passwordField)
														.addComponent(
																formattedTextField,
																GroupLayout.PREFERRED_SIZE,
																218,
																GroupLayout.PREFERRED_SIZE)
														.addComponent(
																btnLogin,
																GroupLayout.PREFERRED_SIZE,
																107,
																GroupLayout.PREFERRED_SIZE))
										.addContainerGap(351, Short.MAX_VALUE)));
		gl_panel_login
				.setVerticalGroup(gl_panel_login
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								Alignment.TRAILING,
								gl_panel_login
										.createSequentialGroup()
										.addContainerGap(61, Short.MAX_VALUE)
										.addGroup(
												gl_panel_login
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(
																lblBenutzername)
														.addComponent(
																formattedTextField,
																GroupLayout.PREFERRED_SIZE,
																35,
																GroupLayout.PREFERRED_SIZE))
										.addGap(35)
										.addGroup(
												gl_panel_login
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(
																lblPassword)
														.addComponent(
																passwordField,
																GroupLayout.PREFERRED_SIZE,
																37,
																GroupLayout.PREFERRED_SIZE))
										.addGap(37)
										.addComponent(btnLogin,
												GroupLayout.PREFERRED_SIZE, 34,
												GroupLayout.PREFERRED_SIZE)
										.addGap(268)));
		panel_login.setLayout(gl_panel_login);

		JPanel panel_verwaltung = new JPanel();
		tabbedPane.addTab("Verwaltung", null, panel_verwaltung, null);
		tabbedPane.setEnabledAt(1, true);

		JButton btnRaumverwaltung = new JButton("Raumverwaltung");
		btnRaumverwaltung.setFont(new Font("Verdana", Font.PLAIN, 12));
		btnRaumverwaltung.addActionListener(this);
		btnRaumverwaltung.setBackground(col);
		btnRaumverwaltung.setFocusable(false);
		// btnRaumverwaltung.setBorder(BorderFactory.createLineBorder(Color.gray,
		// 2));

		JButton btnSitzplatzverwaltung = new JButton("Sitzplatzverwaltung");
		btnSitzplatzverwaltung.setFont(new Font("Verdana", Font.PLAIN, 12));
		btnSitzplatzverwaltung.setFocusable(false);
		btnSitzplatzverwaltung.addActionListener(this);
		// btnSitzplatzverwaltung.setBorder(BorderFactory.createLineBorder(Color.gray,
		// 2));

		JButton btnFilmverwaltung = new JButton("Filmverwaltung");
		btnFilmverwaltung.setFont(new Font("Verdana", Font.PLAIN, 12));
		btnFilmverwaltung.setFocusable(false);
		btnFilmverwaltung.addActionListener(this);
		// btnFilmverwaltung.setBorder(BorderFactory.createLineBorder(Color.gray,
		// 2));

		JButton btnVeranstaltungsverwaltung = new JButton(
				"Veranstaltungsverwaltung");
		btnVeranstaltungsverwaltung
				.setFont(new Font("Verdana", Font.PLAIN, 12));
		btnVeranstaltungsverwaltung.setFocusable(false);
		btnVeranstaltungsverwaltung.addActionListener(this);

		JButton btnUserverwaltung = new JButton("Userverwaltung");
		btnUserverwaltung.setFont(new Font("Verdana", Font.PLAIN, 12));
		btnUserverwaltung.setFocusable(false);
		btnUserverwaltung.addActionListener(this);

		GroupLayout gl_panel_verwaltung = new GroupLayout(panel_verwaltung);
		gl_panel_verwaltung
				.setHorizontalGroup(gl_panel_verwaltung
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_panel_verwaltung
										.createSequentialGroup()
										.addGap(187)
										.addGroup(
												gl_panel_verwaltung
														.createParallelGroup(
																Alignment.TRAILING)
														.addComponent(
																btnUserverwaltung,
																Alignment.LEADING,
																GroupLayout.DEFAULT_SIZE,
																421,
																Short.MAX_VALUE)
														.addComponent(
																btnVeranstaltungsverwaltung,
																Alignment.LEADING,
																GroupLayout.DEFAULT_SIZE,
																421,
																Short.MAX_VALUE)
														.addComponent(
																btnFilmverwaltung,
																Alignment.LEADING,
																GroupLayout.DEFAULT_SIZE,
																421,
																Short.MAX_VALUE)
														.addComponent(
																btnSitzplatzverwaltung,
																Alignment.LEADING,
																GroupLayout.DEFAULT_SIZE,
																421,
																Short.MAX_VALUE)
														.addComponent(
																btnRaumverwaltung,
																Alignment.LEADING,
																GroupLayout.DEFAULT_SIZE,
																421,
																Short.MAX_VALUE))
										.addGap(194)));
		gl_panel_verwaltung.setVerticalGroup(gl_panel_verwaltung
				.createParallelGroup(Alignment.LEADING).addGroup(
						gl_panel_verwaltung
								.createSequentialGroup()
								.addGap(43)
								.addComponent(btnRaumverwaltung,
										GroupLayout.PREFERRED_SIZE, 49,
										GroupLayout.PREFERRED_SIZE)
								.addGap(26)
								.addComponent(btnSitzplatzverwaltung,
										GroupLayout.PREFERRED_SIZE, 50,
										GroupLayout.PREFERRED_SIZE)
								.addGap(29)
								.addComponent(btnFilmverwaltung,
										GroupLayout.PREFERRED_SIZE, 54,
										GroupLayout.PREFERRED_SIZE)
								.addGap(27)
								.addComponent(btnVeranstaltungsverwaltung,
										GroupLayout.PREFERRED_SIZE, 55,
										GroupLayout.PREFERRED_SIZE)
								.addGap(31)
								.addComponent(btnUserverwaltung,
										GroupLayout.PREFERRED_SIZE, 53,
										GroupLayout.PREFERRED_SIZE)
								.addContainerGap(154, Short.MAX_VALUE)));
		panel_verwaltung.setLayout(gl_panel_verwaltung);
		contentPane.setLayout(gl_contentPane);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getActionCommand() == "Sitzplatzverwaltung") {
			dispose();
			TAS t = new TAS();
			t.main(null);
		}

		if (e.getActionCommand() == "Userverwaltung") {
			dispose();
			new Userverwaltung().main(null);
		}

		if (e.getActionCommand() == "Raumverwaltung") {
			dispose();
			new Raumverwaltung().main(null);
		}
		
		if (e.getActionCommand()=="Filmverwaltung"){
			dispose();
		//	new Filmverwaltung(db);//.main(null);                          ACHTUNG!!!!!!!!!!!!!!!!
		}
		
		if (e.getActionCommand()=="Veranstaltungsverwaltung"){
			dispose();
			new Veranstaltungsverwaltung().main(null);
		}
	}

}
